package com.navinfo.tripanalysis.common.arithmetic;

import com.navinfo.tripanalysis.common.arithmetic.annotation.Arithmetic;
import com.navinfo.tripanalysis.common.arithmetic.common.CommonData;
import com.navinfo.tripanalysis.common.arithmetic.common.OuterStatisticData;
import com.navinfo.tripanalysis.common.arithmetic.common.OuterStatisticExtendedData;
import com.navinfo.tripanalysis.common.arithmetic.custom.VarRangeGasOpenPercentUrea;
import com.navinfo.tripanalysis.common.arithmetic.enums.RangeGasOpenPercentEnum;
import com.navinfo.tripanalysis.common.arithmetic.manager.AbstractArithmetic;
import com.navinfo.tripanalysis.common.util.ArithmeticUtils;

/**
 * 东风
 * 油门开度区间尿素消耗统计算法<br/>
 * 输出：统计<br/>
 *
 * @author liudong
 */
@Arithmetic(name = "油门开度区间尿素消耗")
public class RangeGasOpenPercentUrea_DF extends AbstractArithmetic<VarRangeGasOpenPercentUrea> {

    @Override
    public void calculate() {
        logger.debug("进入油门开度区间尿素消耗统计算法.");
        VarRangeGasOpenPercentUrea var = super.getObj();
        CommonData commonData = drivingData.getCommonData();

        int accPedalPos = (int) commonData.getAccelerator();
        if (!RangeGasOpenPercentEnum.RANGE_VALID.getRange().contains(accPedalPos)) {
            return;
        }

        int urea = ArithmeticUtils.massToVolume(commonData.getUreaInjection(), commonData.getAtmosphericTem());
        if (urea == 0) {
            return;
        }
        //累加相应油门开度区间的统计变量
        if (RangeGasOpenPercentEnum.RANGE_0.getRange().contains(accPedalPos)) {
            var.addGasOpenPercent0(urea);
        } else if (RangeGasOpenPercentEnum.RANGE_10.getRange().contains(accPedalPos)) {
            var.addGasOpenPercent10(urea);
        } else if (RangeGasOpenPercentEnum.RANGE_20.getRange().contains(accPedalPos)) {
            var.addGasOpenPercent20(urea);
        } else if (RangeGasOpenPercentEnum.RANGE_30.getRange().contains(accPedalPos)) {
            var.addGasOpenPercent30(urea);
        } else if (RangeGasOpenPercentEnum.RANGE_40.getRange().contains(accPedalPos)) {
            var.addGasOpenPercent40(urea);
        } else if (RangeGasOpenPercentEnum.RANGE_50.getRange().contains(accPedalPos)) {
            var.addGasOpenPercent50(urea);
        } else if (RangeGasOpenPercentEnum.RANGE_60.getRange().contains(accPedalPos)) {
            var.addGasOpenPercent60(urea);
        } else if (RangeGasOpenPercentEnum.RANGE_70.getRange().contains(accPedalPos)) {
            var.addGasOpenPercent70(urea);
        } else if (RangeGasOpenPercentEnum.RANGE_80.getRange().contains(accPedalPos)) {
            var.addGasOpenPercent80(urea);
        } else if (RangeGasOpenPercentEnum.RANGE_90.getRange().contains(accPedalPos)) {
            var.addGasOpenPercent90(urea);
        } else if (RangeGasOpenPercentEnum.RANGE_99.getRange().contains(accPedalPos)) {
            var.addGasOpenPercent99(urea);
        } else if (RangeGasOpenPercentEnum.RANGE_100.getRange().contains(accPedalPos)) {
            var.addGasOpenPercent100(urea);
        }

        logger.debug("油门开度区间尿素消耗统计算法结束.");
    }

    @Override
    public void collect(OuterStatisticData statisticDataOut) {
        VarRangeGasOpenPercentUrea var = super.getObj();

        OuterStatisticExtendedData extendedData = statisticDataOut.getExtendedData();
        extendedData.setGasOpenPercent0Urea(var.getGasOpenPercent0());
        extendedData.setGasOpenPercent10Urea(var.getGasOpenPercent10());
        extendedData.setGasOpenPercent20Urea(var.getGasOpenPercent20());
        extendedData.setGasOpenPercent30Urea(var.getGasOpenPercent30());
        extendedData.setGasOpenPercent40Urea(var.getGasOpenPercent40());
        extendedData.setGasOpenPercent50Urea(var.getGasOpenPercent50());
        extendedData.setGasOpenPercent60Urea(var.getGasOpenPercent60());
        extendedData.setGasOpenPercent70Urea(var.getGasOpenPercent70());
        extendedData.setGasOpenPercent80Urea(var.getGasOpenPercent80());
        extendedData.setGasOpenPercent90Urea(var.getGasOpenPercent90());
        extendedData.setGasOpenPercent99Urea(var.getGasOpenPercent99());
        extendedData.setGasOpenPercent100Urea(var.getGasOpenPercent100());
    }
}
